// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
     point:'',
     building:'',
     rooms:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad({point,building}){
    const rooma = []
    // 总共多少间房
    const length = this.getRandom(1,20)
    for(let i = 0; i <= length; i++){
      // 多少层
      const floor = this.getRandom(1,32)
      // 门牌号
      const num = this.getRandom(1,4)
      const room = `${floor}0${num}`
      // rooma.push(room)
      if(!rooma.includes(room)){
        rooma.push(room)
      }
      rooma.sort((a,b) => {
        return a - b
      })
    }
    this.setData({point,building,rooms:rooma})
  },
  getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min
  }
})